﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MMK.Paket_Tracker.GUI.ViewModels;
using MMK.Paket_Tracker.Runtime.Interfaces;
using MMK.Paket_Tracker.Runtime.Helper;

namespace MMK.Paket_Tracker.GUI.Views
{
    /// <summary>
    /// Interaction logic for NewPacketAddress.xaml
    /// </summary>
    public partial class NewPacketAddressSender : UserControl , INamedUserControl
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="NewPacketAddressSender"/> class.
        /// </summary>
        public NewPacketAddressSender()
        {
            InitializeComponent();
            viewModel = new NewPacketAddressSenderViewModel(this);
            this.DataContext = viewModel.Data;
        }

        #region INamedUserControl Members

        /// <summary>
        /// Gets the name of the view.
        /// </summary>
        /// <value>The name of the view.</value>
        public string ViewName
        {
            get { return "Adresse des Absenders eingeben"; }
        }


        /// <summary>
        /// Sets the error info.
        /// </summary>
        /// <value>
        /// The error info.
        /// </value>
        public Dictionary<String,String> ErrorInfo
        {
            set { errorDict = value; }
        }

        #endregion

        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            this.Vorname.EntryBox.Focus();
        }

        private void OnClick(object sender, RoutedEventArgs e)
        {
            if (viewModel.Data.HasError)
            {
                PTMessageBox.PTMessageBox message = new PTMessageBox.PTMessageBox(this);
                message.Show(errorDict);
            }
        }

        
        private NewPacketAddressSenderViewModel viewModel;
        private Dictionary<String, String> errorDict;
    }
}
